import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './styles/index.scss'
import "@/permission"; // permission control
import Cookies from 'js-cookie';
import "ant-design-vue/dist/antd.css";
import Antd from 'ant-design-vue'
Vue.use(Antd)
Vue.config.productionTip = false



Vue.directive('auth', {
  inserted(el, binding, vnode) {
    const userPermissions = JSON.parse(Cookies.get('permissions'))
      ? JSON.parse(Cookies.get('permissions'))
      : []
    console.log(userPermissions)
    const buttonPermission = binding.value;
    if (!userPermissions.includes(buttonPermission)) {
      el.parentNode.removeChild(el);
      return false;
    }
    return true;
  },
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
